import React, { PropsWithChildren, ComponentType } from "react";
import { Navigate } from "react-router-dom";
type Props = {};

const Hoc_login = (Com: ComponentType<Object>) => {
  return (props: PropsWithChildren<Object>) => {
    const token = localStorage.getItem("token");
    if (!token) {
      return <Navigate to="/login" />;
    } else {
      return <Com {...props} />;
    }
  };
};

export default Hoc_login;
